home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / lex.vim < prev    next >
Encoding:
Text File  |  2001-05-09  |  4.3 KB  |  94 lines

  1. " Vim syntax file
  2. " Language:    Lex
  3. " Maintainer:    Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>
  4. " Last Change:    February 1, 2001
  5. " Option:
  6. "   lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
  7.  
  8. " For version 5.x: Clear all syntax items
  9. " For version 6.x: Quit when a syntax file was already loaded
  10. if version < 600
  11.   syntax clear
  12. elseif exists("b:current_syntax")
  13.   finish
  14. endif
  15.  
  16. " Read the C syntax to start with
  17. if version >= 600
  18.   if exists("lex_uses_cpp")
  19.     runtime! syntax/cpp.vim
  20.   else
  21.     runtime! syntax/c.vim
  22.   endif
  23.   unlet b:current_syntax
  24. else
  25.   if exists("lex_uses_cpp")
  26.     so <sfile>:p:h/cpp.vim
  27.   else
  28.     so <sfile>:p:h/c.vim
  29.   endif
  30. endif
  31.  
  32. " --- Lex stuff ---
  33.  
  34. "I'd prefer to use lex.* , but it doesn't handle forward definitions yet
  35. syn cluster lexListGroup        contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatString,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,lexPatCode,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
  36. syn cluster lexListPatCodeGroup    contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
  37.  
  38. " Abbreviations Section
  39. syn region lexAbbrvBlock    start="^\([a-zA-Z_]\+\t\|%{\)" end="^%%$"me=e-2    skipnl    nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment
  40. syn match  lexAbbrv        "^\I\i*\s"me=e-1            skipwhite    contained nextgroup=lexAbbrvRegExp
  41. syn match  lexAbbrv        "^%[sx]"                    contained
  42. syn match  lexAbbrvRegExp    "\s\S.*$"lc=1                contained nextgroup=lexAbbrv,lexInclude
  43. syn region lexInclude    matchgroup=lexSep    start="^%{" end="%}"    contained    contains=ALLBUT,@lexListGroup
  44. syn region lexAbbrvComment    start="^\s\+/\*"    end="\*/"
  45.  
  46. "%% : Patterns {Actions}
  47. syn region lexPatBlock    matchgroup=Todo    start="^%%$" matchgroup=Todo end="^%%$"    skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
  48. syn region lexPat        start=+\S+ skip="\\\\\|\\."    end="\s"me=e-1    contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
  49. syn region lexBrace    start="\[" skip=+\\\\\|\\+        end="]"        contained
  50. syn region lexPatString    matchgroup=String start=+"+    skip=+\\\\\|\\"+    matchgroup=String end=+"+    contained
  51. syn match  lexPatTag    "^<\I\i*\(,\I\i*\)*>*"            contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
  52. syn match  lexPatTag    +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+        contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
  53. syn region lexPatComment    start="^\s*/\*" end="\*/"        skipnl    contained contains=cTodo nextgroup=lexPatComment,lexPat,lexPatString,lexPatTag
  54. syn match  lexPatCodeLine    ".*$"                    contained contains=ALLBUT,@lexListGroup
  55. syn match  lexMorePat    "\s*|\s*$"            skipnl    contained nextgroup=lexPat,lexPatTag,lexPatComment
  56. syn match  lexPatSep    "\s\+"                    contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
  57. syn match  lexSlashQuote    +\(\\\\\)*\\"+                contained
  58. syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}"    skipnl contained contains=ALLBUT,@lexListPatCodeGroup
  59.  
  60. syn keyword lexCFunctions    BEGIN    input    unput    woutput    yyleng    yylook    yytext
  61. syn keyword lexCFunctions    ECHO    output    winput    wunput    yyless    yymore    yywrap
  62.  
  63. " <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
  64. syn cluster cParenGroup    add=lex.*
  65. syn cluster cDefineGroup    add=lex.*
  66. syn cluster cPreProcGroup    add=lex.*
  67. syn cluster cMultiGroup    add=lex.*
  68.  
  69. " Synchronization
  70. syn sync clear
  71. syn sync minlines=300
  72. syn sync match lexSyncPat    grouphere  lexPatBlock    "^%[a-zA-Z]"
  73. syn sync match lexSyncPat    groupthere lexPatBlock    "^<$"
  74. syn sync match lexSyncPat    groupthere lexPatBlock    "^%%$"
  75.  
  76. " The default highlighting.
  77. hi def link lexSlashQuote    lexPat
  78. hi def link lexBrace    lexPat
  79. hi def link lexAbbrvComment    lexPatComment
  80.  
  81. hi def link lexAbbrv    SpecialChar
  82. hi def link lexAbbrvRegExp    Macro
  83. hi def link lexCFunctions    Function
  84. hi def link lexMorePat    SpecialChar
  85. hi def link lexPat        Function
  86. hi def link lexPatComment    Comment
  87. hi def link lexPatString    Function
  88. hi def link lexPatTag    Special
  89. hi def link lexSep        Delimiter
  90.  
  91. let b:current_syntax = "lex"
  92.  
  93. " vim:ts=10
  94.